package com.boluo.web.controller.businessManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.boluo.businessManagement.dto.BusMentStoreOpinfoDTO;
import com.boluo.businessManagement.vo.BusMentStoreOpinfoVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boluo.common.annotation.Log;
import com.boluo.common.core.controller.BaseController;
import com.boluo.common.core.domain.AjaxResult;
import com.boluo.common.enums.BusinessType;
import com.boluo.businessManagement.domain.BusMentStoreOpinfo;
import com.boluo.businessManagement.service.IBusMentStoreOpinfoService;
import com.boluo.common.utils.poi.ExcelUtil;
import com.boluo.common.core.page.TableDataInfo;

/**
 * 出入库管理Controller
 * 
 * @author SekonoAlpaca
 * @date 2023-05-03
 */
@RestController
@RequestMapping("/businessManagement/opInfo")
public class BusMentStoreOpinfoController extends BaseController
{
    @Autowired
    private IBusMentStoreOpinfoService busMentStoreOpinfoService;

    /**
     * 根据入库单据id 查明细
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:query')")
    @GetMapping(value = "/getBillAndOpInfo/{billId}")
    public AjaxResult getBillAndOpInfo(@PathVariable("billId") Long billId)
    {
        return AjaxResult.success(busMentStoreOpinfoService.selectBusMentStoreOpinfoBybillId(billId));
    }


    /**
     * 查询出入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusMentStoreOpinfo busMentStoreOpinfo)
    {
        startPage();
        List<BusMentStoreOpinfo> list = busMentStoreOpinfoService.selectBusMentStoreOpinfoList(busMentStoreOpinfo);
        return getDataTable(list);
    }
    /**
     * 四表联查:出入库管理页面及详细页面所需所有数据
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:list')")
    @GetMapping("/complexList")
    public TableDataInfo Complexlist(BusMentStoreOpinfo busMentStoreOpinfo)
    {
        startPage();
        List<BusMentStoreOpinfoVO> list = busMentStoreOpinfoService.selectBusMentStoreOpinfoListAndBill(busMentStoreOpinfo);
        return getDataTable(list);
    }

    /**
     * 导出出入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:export')")
    @Log(title = "出入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusMentStoreOpinfo busMentStoreOpinfo)
    {
        List<BusMentStoreOpinfo> list = busMentStoreOpinfoService.selectBusMentStoreOpinfoList(busMentStoreOpinfo);
        ExcelUtil<BusMentStoreOpinfo> util = new ExcelUtil<BusMentStoreOpinfo>(BusMentStoreOpinfo.class);
        util.exportExcel(response, list, "出入库管理数据");
    }

    /**
     * 获取出入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(busMentStoreOpinfoService.selectBusMentStoreOpinfoById(id));
    }

    /**
     * 新增出入库管理
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:add')")
    @Log(title = "出入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusMentStoreOpinfoDTO busMentStoreOpinfoDTO)
    {
        return toAjax(busMentStoreOpinfoService.insertBusMentStoreOpinfo(busMentStoreOpinfoDTO));
    }

    /**
     * 修改出入库管理
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:edit')")
    @Log(title = "出入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusMentStoreOpinfo busMentStoreOpinfo)
    {
        return toAjax(busMentStoreOpinfoService.updateBusMentStoreOpinfo(busMentStoreOpinfo));
    }

    /**
     * 删除出入库管理
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:remove')")
    @Log(title = "出入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busMentStoreOpinfoService.deleteBusMentStoreOpinfoByIds(ids));
    }
    /**
     *逻辑删除出入库管理
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:opInfo:remove')")
    @Log(title = "出入库管理", businessType = BusinessType.DELETE)
    @PutMapping("delLogical/{id}")
    public AjaxResult deleteLogical(@PathVariable Long id)
    {
        return AjaxResult.success(busMentStoreOpinfoService.deleteBusMentStoreOpinfoByIdOnLogical(id));
    }
}
